package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:setDaemon()方法的测试
 * User: 王圆豪
 * Date: 2025-04-23
 * Time: 0:24
 */
public class Demo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            while(true) {
                System.out.println("Hello thread!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        //thread.setDaemon(true);
        thread.start();

        for(int i = 0; i < 3; i++){
            System.out.println("Hello main!");
            Thread.sleep(1000);
        }
    }
}
